var read_line = require('readline-sync')
read_line.setDefaultOptions({ prompt: '' })
var read_line = read_line.prompt
let n = parseInt(read_line())  // 读出字符串的个数
let arr = []
for (let i = 0; i < n; i++) {
  let str = read_line()
  arr.push(str) // 存入arr数组中
}
let result = 0
function getMax (str) {
  let map = {}
  for (let i of str) {
    map[i] = (map[i] || 0) + 1 // 得到每一个出现的个数
  }
  console.log(map)
  let max = 0 // 初始的最大值是0
  let min = Infinity // 初始的最小值是无穷大
  for (let key in map) {
    if (map[key] > max) {
      max = map[key]
    }
    if (map[key] < min) {
      min = map[key]
    }
  }
  console.log(max, min);
  let res = max - min // 得到这个的分数
  return res // 返回这个分数
}
for (let i = 0; i < n; i++) {
  result = Math.max(result, getMax(arr[i]))
}
console.log(result)